home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / music / c2snd201.zip / CONV2SND.DOC < prev    next >
Text File  |  1994-09-11  |  23KB  |  483 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                        (******CONV2SND.DOC******)
  7.                         *                      *
  8.                         *  CONV2SND.PAS: 2.00  *
  9.                         *                      *
  10.                         *   February 3, 1993   *
  11.                         *     Kenneth Udut     *
  12.                         *    Revised 6/22/94   *
  13.                         *      J.L. Hayes      *
  14.                         *                      *
  15.                        (******CONV2SND.DOC******)
  16.  
  17.  
  18.  
  19.  
  20.  
  21. CONV2SND.EXE, CONV2SND.PAS, CONV2SND.DOC, CONV2SND.HST HEREBY ARE
  22. RELEASED INTO THE PUBLIC DOMAIN.  UNLESS SPECIAL CIRCUMSTANCES WARRANT
  23. OTHERWISE, EVERY SOFTWARE PRODUCT CREATED BY (_KENNETH UDUT_) WILL:
  24.  
  25. 1. BE RELEASED INTO THE PUBLIC DOMAIN, FREELY COPYABLE AND CHANGEABLE.
  26.  
  27. 2. INCLUDE THE SOURCE CODE.
  28.  
  29. AS THE AUTHOR OF (_CONV2SND_), I WOULDN'T MIND CREDIT FOR MY WORK.  
  30. HOWEVER, IT IS *NOT* A NECESSITY, SO DON'T WORRY ABOUT IT! :)
  31.  
  32. [Note: My modifications are also public domain.  Ken wrote much of the 
  33. following, but I have changed a lot of it to match version 2.00. - J.L. 
  34. Hayes]
  35.  
  36. Now enough of this screaming!
  37.  
  38.  
  39.  
  40. 1.  CONV2SND is a program with one thing in mind:  To open the worlds
  41.     of digitized sounds created on other machines and by other methods
  42.     to anyone using a Tandy 1000 SL, TL, RL, RLX, 2500 RLX, RSX and
  43.     every other machine that uses:
  44.  
  45.     SOUND.PDM
  46.  
  47.     Ken wrote: "I wish that Tandy had created something a few years ago 
  48.     that would have done this, as it might have kept the Tandy's with the 
  49.     superb 8-bit DAC a little more in step with the SoundBlaster, the 
  50.     Macintosh, the Amiga and the Atari ST, all of which are able to create 
  51.     superb digitized sounds and have programs that allow you to share them 
  52.     with one another.
  53.  
  54.     "So, here it is."
  55.  
  56.  
  57. 2.  To start the program, type:
  58.  
  59.         CONV2SND <infile>
  60.  
  61.     or:
  62.  
  63.         CONV2SND <infile> <outfile>
  64.  
  65.     The process will then take place automatically.  Filenames can include 
  66.     drive and path if you want.  If you use the first form, the output 
  67.     filename will be the same as the input filename, including drive and 
  68.     path if present, but with an ".snd" extension attached.  If you use the 
  69.     second form, the output filename will be what you specified.  If the 
  70.     output filename does not have an extension, it defaults to ".snd".  
  71.     There is no default for the input file, so you have to specify the 
  72.     extension for it.  If you want the output file not to have an 
  73.     extension, end its name with a period.
  74.  
  75.     As of version 2.00, CONV2SND can read and understand .wav headers.  The 
  76.     .wav will be detected by the header, not by the filename.  CONV2SND 
  77.     will check that the .wav is an 8-bit mono file and display some advice 
  78.     if it isn't (see below).  If the .wav is 8-bit mono, CONV2SND will read 
  79.     the sampling rate from the header and check to see if it is within 5% 
  80.     of one of the three rates supported by Sound.pdm.  If so, the sampling 
  81.     rate will be taken from the .wav header, and you won't be asked about 
  82.     that.  If not, you will be told to resample the file.  There is a 
  83.     program available to do this, discussed below.  If the .wav header is 
  84.     invalid, you will be given the option of continuing as if the file were 
  85.     not a .wav.  I don't know how useful that will be.
  86.  
  87.     You will be asked a couple of questions.
  88.  
  89.     A) Asks about the sampling rate (speed of playback).  You won't be 
  90.        asked this question if CONV2SND is able to determine the sampling 
  91.        rate from the .wav header.
  92.  
  93.        These are the options (Ken's notes):
  94.  
  95.        5500 is a slow sampling rate, often used for speech purposes or some
  96.             games.  [5500 seems to be rare nowadays. - JLH]
  97.  
  98.        11000 is the the most common sampling rate.  It is #2 on the 
  99.              selection list and the one you will want to try first.  The 
  100.              only reason it is so popular is that it is of sufficient 
  101.              quality for music and such.  5500 really isn't.  WAV files are 
  102.              usually sampled at 11000 samples per second.
  103.  
  104.        22000 is most often used with the Macintosh Sound files.  It is of a 
  105.              higher quality, but it does take up more disk space, which is 
  106.              why it is the 2nd most popular sampling rate to record at.  
  107.              [This rate is becoming more common. - JLH]
  108.  
  109.        If you screw up and select the wrong one, that's okay!  Just redo the
  110.        procedure and select a different rate next time!
  111.  
  112.        [It should be mentioned that 44000, or 44kHz, is an increasingly 
  113.        common rate.  This is the rate that audio CD's are sampled at.  The 
  114.        Tandy sound chip is perfectly capable of going that fast, but 
  115.        Sound.pdm does not support that speed.  I have written a .wav player 
  116.        for the Tandy chip that will play .wav's at 44kHz - see Snd2wav.doc.  
  117.        Included here with CONV2SND is a utility called Ppwav that can cut 
  118.        the sampling rate of these .wav's down to 22kHz so that CONV2SND can 
  119.        convert them.  See below. - JLH]
  120.  
  121.     B) Asks for the "name" of the sound.
  122.  
  123.        This isn't the file name.  This is the name that appears when you 
  124.        are in SOUND.PDM, right next to "Name: ", in the right hand box.  If 
  125.        you don't specify a name, none will be used.  This is a change from 
  126.        version 1.98, which required you to enter a name.  It is a good idea 
  127.        to specify a name anyway, in case the name of the file gets changed 
  128.        at some point in the future.
  129.  
  130.        You can read the name of the sound by typing DEBUG filename.snd and 
  131.        then "d".  You will see the name of the sound file in the right hand 
  132.        side of the screen.  (NOTE: "q" gets you out of DEBUG)
  133.  
  134.     C) Asks for your name.  "No real reason yet, but I'm thinking of one!" 
  135.        writes Ken.  Version 1.98 required you to enter your name; this 
  136.        version will call you "CONV2SND user" if you don't enter a name.
  137.  
  138.  
  139.     A new file with your sound will be created.  This is the DeskMate SOUND 
  140.     version of the other digitized file.
  141.  
  142.  
  143. 3.  You will need to do the following after the file is created:
  144.  
  145.  
  146.     * Go into SOUND.PDM, and load the new .SND file (F2, Open)
  147.  
  148.     * Play the file and see if the conversion was done right.  If the file
  149.       sounds like Alvin the Chipmunk, the sampling rate you gave was too 
  150.       low; go back and run CONV2SND again with a higher rate.  If it sounds 
  151.       like Lurch on "The Addams Family," the rate is too high, and you need 
  152.       to try a lower one.  (That is, unless the file *is* a recording of 
  153.       Lurch! :-)  If the file sounds like nothing at all, just static, it 
  154.       may not be an 8-bit mono PCM file.  You will have to use a program 
  155.       called Sox to convert it to one before CONV2SND can use it; see 
  156.       below.
  157.  
  158.       If the input file was a .wav, you should not have this problem.  If 
  159.       the .wav is of a type that can't be converted (most can), CONV2SND 
  160.       will tell you why and halt without creating an output file.
  161.  
  162.     * If the sampling rate seems right, carefully remove any noise at the 
  163.       beginning of the file, using a very small increment (use "sample").  
  164.       Beginning noise, if present, represents the header of the original 
  165.       sound file; it is not actual sound.  There are a few types of sound 
  166.       files that don't have a header ("raw" files made by Sox are one - see 
  167.       below), but most do.  The noise will be a short click or pop.
  168.  
  169.       Again, if the input file was a .wav, the .wav header will be deleted 
  170.       automatically, and this problem will not arise.
  171.  
  172.     * Hit F2 and Save the file.
  173.  
  174.       Example: ROCKY.WAV is converted into ROCKY.SND
  175.          After listening to the file to check the conversion and getting 
  176.          rid of the little beginning noise, hit F2, and Save.  Exit 
  177.          SOUND.PDM if you don't want to do more with the file at that time.
  178.  
  179.  
  180. Here are some problems you may have, and what to do about them:
  181.  
  182.     * If the file sounds like nothing at all, just static, it may not be an 
  183.       8-bit unsigned mono PCM file.  That means the sound data in the file 
  184.       is not the right type for SOUND.PDM, and it will have to be converted 
  185.       to 8-bit unsigned mono PCM before CONV2SND can use it.  There is a 
  186.       program called Sox that can tell you what kind of file it is and do 
  187.       the conversion.  As of this writing (6/22/1994), Sox is available by 
  188.       ftp from:
  189.  
  190.         oak.oakland.edu
  191.  
  192.       Get file:
  193.  
  194.         /pub/msdos/sounds/sox7dos.zip
  195.  
  196.       and read the documentation that comes with Sox.  You will need to 
  197.       tell Sox to make its output file a RIFF WAVE file, size "byte," "1 
  198.       channel" and select a sampling rate of 5500, 11000, or 22000.  Use 
  199.       the "verbose" option with the "stat" effect to find out what the 
  200.       sampling rate of the original file is; if it's close to one of those 
  201.       three, leave it alone.  CONV2SND will accept sampling rates within 5% 
  202.       of 5500, 11000, or 22000.  It is best not to resample if you don't 
  203.       have to since it introduces noise.  Warning: Sox is a little 
  204.       confusing to use at first.
  205.  
  206.       As an alternative to Sox, this distribution includes a utility called 
  207.       Ppwav that operates only on .wav files.  Ppwav can convert wav's with 
  208.       more than one channel to mono and larger sample sizes to 8-bit.  It 
  209.       can also cut the sampling rate of a file in half.  Sox does all that 
  210.       Ppwav does and more, but Ppwav is much faster and easier to use.  If 
  211.       you have a .wav that can't be converted because of one of the 
  212.       problems that Ppwav can solve, CONV2SND will refuse to convert the 
  213.       file and tell you to use Ppwav.  See the separate documentation file 
  214.       on Ppwav.  Note that there are rare types of .wav's that neither Sox 
  215.       nor Ppwav can convert.
  216.  
  217.     * If you've tried all 3 sampling rates, 5500, 11000, and 22000, and 
  218.       none of them seems to be right, you will have to resample the sound 
  219.       to change the sampling rate to one of those three.  SOUND.PDM can 
  220.       only use one of those 3 rates.  Sox (see above) can be used to do 
  221.       this.  Changing the sampling rate will introduce noise, unfortun- 
  222.       ately; change to a sampling rate that is an integer multiple of the 
  223.       original to minimize the noise.
  224.  
  225.       Other sampling rates that I have seen are 8000, 15000, and 44000.  
  226.       Sun .au files are usually sampled at 8000 (note that Sun .au is not 
  227.       PCM but mu-law - Sox can convert these to .wav).  If the input file 
  228.       is a .wav, CONV2SND will refuse to convert the file if the header 
  229.       indicates that the sampling rate is not one of the three that 
  230.       Sound.pdm supports.
  231.  
  232.     * If CONV2SND tells you the disk where the output file goes is full, 
  233.       you will need to specify another drive for the output file, one with 
  234.       more space on it.  If you have a single-floppy system, you can 
  235.       specify drive B:, and DOS will prompt you to swap disks when needed.  
  236.       It will be awkward to do it this way, but it will work.
  237.  
  238.     * If Sound.pdm tells you the .snd file won't fit in memory, there is 
  239.       unfortunately not much you can do.  If your system can take 
  240.       additional DOS memory, you can install additional memory if you 
  241.       haven't already.  This is a very cheap upgrade and highly 
  242.       recommended; check your owner's manual to find out how.  I'm 
  243.       referring to systems with less than 640k of DOS memory; I doubt that 
  244.       Sound.pdm will use expanded or extended.
  245.  
  246.  
  247. That's it!  Ken's phone (908) 241-6246 is open for your use up 'till about 
  248. 11pm or so.  He is kudut@ritz.mordor.com on the Internet, and Kenneth Udut, 
  249. 170 East Clay Avenue, Roselle Park, NJ USA 07204-2050.
  250.  
  251. Note: Ken hasn't worked with this program in a while, but I expect he will 
  252. continue to act as a clearinghouse for the various modifiers, such as 
  253. myself.  I am responsible for the modifications from version 1.98 to 
  254. version 2.00, including much of the above text.  My phone is (207) 866- 
  255. 7903.  I'm tvdog@delphi.com on the Internet.  Snailmail: Jeffrey L. Hayes, 
  256. 130 Forest Ave., Lot 1, Orono, Maine 04473.
  257.  
  258. "Thanks for reading and hope you NOT ONLY enjoy using it, but also play 
  259. around with the source code and work with it!  
  260.  
  261. "I want to see a world where source code is freely distributable, where 
  262. there isn't all that "data-hiding" and all that.  I would hate to see a 
  263. society where the 'elite programmers' only knew the secrets of 'real' 
  264. programming, while the peons were kept down low...
  265.  
  266. "I prefer openness and honesty, personally :)
  267.  
  268. "Talk to you soon!
  269.  
  270. "--Ken
  271.  
  272. "February 3, 1993"
  273.  
  274.  
  275. FIDONET: Kenneth Udut @ 1:107/900
  276. INTERNET: kudut@ritz.mordor.com
  277. America Online: K Udut
  278. PC-Link: K Udut
  279. CompuServe: INTERNET> kudut@ritz.mordor.com
  280. BITNET: kudut%ritz.mordor.com@yalevm.bitnet
  281.  
  282. Home Address:
  283. Kenneth Udut
  284. 170 East Clay Avenue
  285. Roselle Park, New Jersey 07204-2050
  286.  
  287. Phone Numbers:
  288. (908) 241-6246
  289. (908) 241-8528  --  FAX number
  290.  
  291. Can be found on:
  292. The Juice Bar BBS, located in Roselle Park, New Jersey, USA
  293. (908) 298-0764.  I'm user #11, and a VERY VERY active poster!
  294.  
  295. I also run a list on BITNET. 
  296. Y-RIGHTS@SJUVM.BITNET - discussion on the rights of kids and teens.
  297.  
  298.  
  299. "Leave me a message somewhere or give me a phone call!  I'll set a pot of 
  300. tea out for you and we'll chat :)" - Ken
  301.  
  302.  
  303. Also check out the Tandy sound package, now on Simtel!  Play mono or stereo 
  304. 8- or 16-bit .wav's of arbitrary size at up to 65535 Hz, record .wav's of 
  305. arbitrary length at up to 62kHz, convert raw 8-bit sound files to .wav, 
  306. convert 16-bit or stereo .wav's to mono 8-bit, convert .snd instrument 
  307. files to Amiga .mod samples (including looped samples!), use your Tandy DAC 
  308. with programs that support a generic DAC, and play your Tandy like a piano 
  309. with the 3-voice chip (chords too!).  All source code included, and the 
  310. best, most complete programming information on the Tandy sound that you 
  311. will find anywhere!  All free!  How do I get this marvellous package, you 
  312. ask?  Just ftp it from:
  313.  
  314.   oak.oakland.edu:/pub/msdos/sound/tspak.zip
  315.  
  316. - JLH
  317.  
  318.  
  319.  
  320.  
  321.            -----------[technical stuff]------------
  322.  
  323.  
  324.  
  325.  
  326. Many (but not all) types of sound files are basically identical to DeskMate 
  327. .snd.  That is, the actual sound data is encoded in exactly the same way.  
  328. The difference lies in the "header."
  329.  
  330. The header of a file is a small series of bytes, usually 44 in the case of 
  331. DeskMate .snd files.  The purpose of a header?
  332.  
  333. A header tells the program how big the file is, as most programs that read 
  334. digitized sound files need to be specially told how many bits of sound they 
  335. need to load up.  It also might tell you the "name" or description of the 
  336. sound file.  The sampling rate (how fast the sound was recorded and should 
  337. be played back) is also usually included.
  338.  
  339. Christopher Taveres was the first to try to decode the .snd header.  
  340. Chris's effort appeared as part of his SOUNDOFF.C program in _PCM_, the 
  341. Tandy magazine.  Here's what he came up with:
  342.  
  343. ======================================================================
  344.  
  345. /* Sound Off!
  346. /* Written by Christopher Taveres 
  347. /* Copyright (c) January 1992
  348. /* Falsoft, Inc.
  349. /* PCM
  350. /** Definintion for the header block for Deskmate .snd files **/
  351.  
  352. struct dmheader {            /* Structure of the header block      */
  353.        int marker;           /* Marker bytes - should be 00 1a     */
  354.        char note_count;      /* Number of notes in instrument file */
  355.        char inst_num;        /* Instrument number                  */
  356.        char inst_name[10];   /* Instrument name                    */
  357.        int sample_rate;      /* Sampling rate                      */
  358.        char filler[16];      /* I don't know what this does        */
  359.        unsigned long sample_size;  /* Number of samples in file    */
  360.        char filler2[8];      /* More unknown space                 */
  361.  
  362. ======================================================================
  363.  
  364. Ken noticed that the marker bytes could be 1A 01 instead of 1A 00.  The 
  365. number of samples confused him, however.  After fiddling around with 
  366. Sound.pdm for a while, I filled in most of the blanks as follows:
  367.  
  368. TANDY DESKMATE .SND FORMAT NOTES
  369.  
  370. There are two types of DeskMate .snd files, sound files and instrument files.
  371. Both contain 8-bit unsigned PCM samples.  "PCM" stands for "pulse code
  372. modulation" and just means that the sound wave is measured at fixed intervals
  373. and its level recorded.  It's just like you used to do in high school algebra
  374. when you were asked to graph a function by evaluating it at various points.
  375. With PCM, the samples are integers in a certain range; the Tandy sound chip
  376. uses 0-255.
  377.  
  378. Sound files are simpler.  These are garden-variety sample files with a fixed-
  379. length header giving the name of the sound, the recording frequency, and the
  380. length of the sound.  Sound files may be recorded at 5500Hz, 11kHz or 22kHz.
  381.  
  382. Instrument files contain samples as well as frequency and looping information
  383. used by Music.pdm to represent an instrument.  Instrument files provide for
  384. attack, sustain, and decay with several samples having different implied
  385. frequencies and being used by Music.pdm to represent the instrument in
  386. different pitch ranges.  Up to 16 different notes (with 16 different samples)
  387. can be contained in one instrument file.  Instrument files are always recorded
  388. at 11kHz.
  389.  
  390. Both sound files and instrument files may be compressed in one of two ways,
  391. "music" compression or "speech" compression, or they may be uncompressed.  I
  392. don't know the compression algorithms, but simple file comparison reveals that
  393. "music" and "speech" compression are almost identical.
  394.  
  395. The DeskMate .snd file header consists of 16 bytes of fixed header information
  396. followed by one or more 28-byte note records.  The sample information, which
  397. may be compressed, follows the header.
  398.  
  399. The information below is the old-format .snd header used by the 1000-series.
  400. This is the format written by CONV2SND.  The 2500's use a somewhat different
  401. header when writing (see Snd2wav.doc), but they can read the old format.
  402.  
  403.  
  404. DeskMate .snd File Format - Fixed Header
  405. ----------------------------------------
  406.  
  407.   offset    size      what
  408.   ------    ----      ----
  409.  
  410.   0         byte      1Ah (.snd ID byte).  Note that 1Ah = <cntrl>-Z, so if 
  411.                       a user attempts to type the .snd file to the screen, 
  412.                       nothing will be displayed.
  413.  
  414.   1         byte      Compression code:  0 = no compression; 1 = music
  415.                       compression; 2 = speech compression.
  416.  
  417.   2         byte      Number of notes in the instrument file.  1 if sound
  418.                       file.  There can be up to 16 notes in an instrument
  419.                       file.  Note:  when an instrument file is created, it
  420.                       automatically has one unset note placed in it.
  421.  
  422.   3         byte      Instrument number.  0 if sound file; 0FFh if instrument
  423.                       file with no number set.  Valid instrument numbers in
  424.                       an instrument file are 1 to 32.  Use this field to
  425.                       distinguish a sound file from an instrument file.
  426.  
  427.   4         10 bytes  Sound or instrument name.  Name is a null-terminated
  428.                       string, so there are up to 9 characters of the name,
  429.                       plus the null byte.
  430.  
  431.   0Eh       word      Sampling rate in samples per second.  Note that although
  432.                       a sampling rate other than 5500, 11000 and 22000 can be
  433.                       entered here, Sound.pdm will not actually play at other
  434.                       rates.
  435.  
  436.   10h       variable  Note records begin, 28 bytes each.  Number of records
  437.                       given in byte 2 above.
  438.  
  439.  
  440. DeskMate .snd File Format - Note Record
  441. ---------------------------------------
  442.  
  443.   0         byte      Pitch of the note:  1 = A1 in American Standard Pitch;
  444.                       2 = A#1; etc.  A1 is lowest note allowed; highest note
  445.                       allowed is B6 (3Fh).  Sound files have 0FFh here; so do
  446.                       instrument files with no note set.
  447.                           Note that Sound.pdm does not designate notes in the
  448.                       standard manner to the user.  Although A1 and B6 in
  449.                       Sound.pdm are the same as A1 and B6 in standard pitch,
  450.                       Sound.pdm starts octaves at A rather than at C (as is
  451.                       standard).  Thus, middle C, C4 in standard pitch, is C3
  452.                       in Sound.pdm.
  453.  
  454.   1         byte      Sound files, and instrument files with no pitch set,
  455.                       have 0 here.  If the pitch is set, this byte is 0FFh.
  456.  
  457.   2         2 bytes   Range of the note, first byte is lower limit, second
  458.                       is higher limit.  Byte encoding as for offset 0 (i.e.,
  459.                       01h to 3Fh).  Sound files have FF FF here; so do
  460.                       instrument files with no range set.
  461.  
  462.   4         dword     Offset in the file where samples for this note begin
  463.                       (zero-relative), after compression if that was done.
  464.  
  465.   8         dword     If compressed, the length of the compressed data in the
  466.                       file for this note.  Uncompressed files have 0 here.
  467.  
  468.   0Ch       4 bytes   Unknown.  Set to zero.
  469.  
  470.   10h       dword     Number of samples in the note, after decompression if
  471.                       necessary.  0 can appear here, meaning the note is not
  472.                       set, or the sound file is empty.
  473.  
  474.   14h       dword     Number of sample at start of sustain region for the
  475.                       note, relative to the first (zeroth) sample of the note.
  476.                       For sound files, or if sustain is not set, this field is
  477.                       0.
  478.  
  479.   18h       dword     Number of sample at end of sustain region for the note,
  480.                       relative to the first (zeroth) sample of the note.  For
  481.                       sound files, or if sustain is not set, this field is 0.
  482.  
  483. //// end of conv2snd.doc ////